import 'package:bilibili/util/color.dart';
import 'package:flutter/material.dart';

class LoginButton extends StatefulWidget {
  final String title;
  final bool enable;
  final bool isOutLine;
  final VoidCallback? onPressed;
  const LoginButton(this.title,
      {Key? key, this.enable = true, this.isOutLine = false, this.onPressed})
      : super(key: key);

  @override
  _LoginButtonState createState() => _LoginButtonState();
}

class _LoginButtonState extends State<LoginButton> {
  @override
  Widget build(BuildContext context) {
    return widget.isOutLine
        ? OutlinedButton(
            style: OutlinedButton.styleFrom(
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(5),
                ),
                side: BorderSide(width: 1, color: primary)),
            onPressed: widget.enable ? widget.onPressed : null,
            child: Container(
              height: 45,
              alignment: Alignment.center,
              child: Text(
                widget.title,
                style: TextStyle(color: primary, fontSize: 16),
              ),
            ),
          )
        : MaterialButton(
            shape:
                RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)),
            height: 45,
            onPressed: widget.enable ? widget.onPressed : null,
            disabledColor: primary[50],
            color: primary,
            child: Text(widget.title,
                style: TextStyle(color: Colors.white, fontSize: 16)),
          );
  }
}
